// 创建一个接口
interface IUser {
  name: string;
  age: number;
  [propNam: string]: any; // 任意属性
  sayHi1?: () => void; // ? 表示可选属性
  sayHi2: (name: string) => string;
}

let p4: IUser = {
  name: '张三',
  age: 18,
  sayHi1() {
    console.log('你我皆凡人');
  },
  sayHi2(name: string) {
    return `你好${name}`;
  },
};

let p5: IUser = {
  name: '李四',
  age: 28,
  sayHi2(name: string) {
    return `你好${name}`;
  },
};

// 访问属性、调用方法
console.log('姓名：', p4.name);
console.log('sayHi2：', p4.sayHi2(p4.name));
